package battle_behavior

import (
	"confs/gen/common"
	"game/app/actors/schemas"
	"game/app/systems/battle_system"
	"game/app/systems/move_system"
	"gos/modules/logger"
)

// BattlePlayerBehavior
type BattlePlayerBehavior struct{}

func init() {
	battle_system.BattleBehavior.Register(common.BattleEntityType_BattlePlayer, BattlePlayerBehavior{})
}

func (b BattlePlayerBehavior) BeginBattle(state *schemas.MoveState, entity *schemas.BattleEntity) bool {
	return true
}

func (b BattlePlayerBehavior) EndBattle(state *schemas.MoveState, entity *schemas.BattleEntity, stop bool) bool {
	moveEntity := state.GetMoving(entity.Id)
	if moveEntity == nil {
		logger.ERR("结束战斗 无法找到实体:", entity.Id)
		return false
	}

	// 如果自己死了，在追击状态,那么结束追击
	if entity.IsDead {
		// 删除自己的追击状态
		state.DeleteBattleAIEntityWrap(moveEntity)
		stop = false
	} else {

	}

	if !stop {
		move_system.Move.StopFollow(state, moveEntity)
	}
	return true
}

func (b BattlePlayerBehavior) RoundBegin(state *schemas.MoveState, entity *schemas.BattleEntity, battle *schemas.Battle) {

}

func (b BattlePlayerBehavior) SetDead(state *schemas.MoveState, entity *schemas.BattleEntity) {

}
